<%-- 
    Document   : testDb.jsp
    Created on : 2012. 4. 9, 오후 6:12:01
    Author     : jeong
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.List"%>
<%@page import="com.webproject.jsp.common.CommonUtil"%>
<%@page errorPage="../error/errorView.jsp"%>

<html>
<%
    Statement stmt = null;
    Connection con = null;
    
    try {
%>
<%@include file="include/dbConnect.jsp"%>
<%
        con = DriverManager.getConnection(url, user, password);
        stmt = con.createStatement();

        //String selectSQL = "select  profile_name, profile_sex, profile_age, profile_born, profile_birth, profile_blood, profile_job from profile";
        String selectSQL = "select  NUM, TITLE, CONTENT, PASSWRD, REG_DATE from board01";
        ResultSet rs = stmt.executeQuery(selectSQL);
%>

<div>
    <table id="tb1" cellpadding="0" cellspacing="0" align="center">
        <th>NO&nbsp;</th><th>성명&nbsp;</th><th>성별&nbsp;</th><th>나이&nbsp;</th><th>출생지&nbsp;</th><th>생년월일&nbsp;</th><th>혈액형&nbsp;</th><th>직업&nbsp;</th>
        <td colspan="8" align="center" height="100">&nbsp;</td>
<%
           int count = 0;
           int cnt = CommonUtil.getResultSetSize(rs);
           
           System.out.println(">>> cnt : " + cnt + "\n");
           
           if(cnt > 0) {
                while(rs.next()) {
%>
        <tr>
            <!--
            <td><%=count+1%></td><td><%=rs.getString("profile_name")%></td><td><%=rs.getString("profile_sex")%></td><td><%=rs.getInt("profile_age")%></td><td><%=rs.getString("profile_born")%></td><td><%=rs.getString("profile_birth")%></td><td><%=rs.getString("profile_blood")%></td><td><%=rs.getString("profile_job")%></td>
            //-->
            <td><%=count+1%></td><td><%=rs.getInt("NUM")%></td><td><%=rs.getString("TITLE")%></td><td><%=rs.getString("CONTENT")%></td><td><%=rs.getString("PASSWRD")%></td><td><%=rs.getString("REG_DATE")%></td><td>&nbps;</td><td>&nbsp;</td>
        </tr>   
<%              
                count++;
                }
        } else {
%>
        <tr>    
            <td colspan="8" align="center" height="100">해당 데이타가 없습니다.</td>
        </tr>      
<%
        }
%>
    </table>
</div>
<%
   } catch(Exception e) {
       e.printStackTrace();
   } finally {
       if(stmt!=null) {
           try {
               stmt.close();
           } catch(SQLException sqle) {
           }
       }
       if(con !=null) {
           try {
               con.close();
           } catch(SQLException sqle) {
           }
       }
   }
%>
</html>